# 安装wget
yum install -y wget

# 备份默认源
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
# 替换阿里云源
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
yum makecache

# 安装jdk
tar -zvxf /opt/jdk-8u171-linux-x64.tar.gz -C /usr/local

#配置jdk环境变量
echo "JAVA_HOME=/usr/local/jdk1.8.0_171" >> /etc/profile

# 建立软连接
ln -s /usr/local/jdk1.8.0_171/bin/java /usr/bin/java
# 安装maven
cd /opt
tar -zvxf /opt/apache-maven-3.5.4-bin.tar.gz

#配置maven环境变量
echo "MAVEN_HOME=/opt/apache-maven-3.5.4" >> /etc/profile

echo "PATH=\$JAVA_HOME/bin:\$MAVEN_HOME/bin:\$PATH">> /etc/profile

# 重新加载配置文件
source /etc/profile

# 安装docker
yum install docker -y

echo "{" > /etc/docker/daemon.json
echo "	\"registry-mirrors\" : [">>/etc/docker/daemon.json
echo "		\"https://registry.docker-cn.com\",">>/etc/docker/daemon.json
echo "		\"https://docker.mirrors.ustc.edu.cn\",">>/etc/docker/daemon.json
echo "		\"http://hub-mirror.c.163.com\"">>/etc/docker/daemon.json
echo "	]" >>/etc/docker/daemon.json
echo "}" >>/etc/docker/daemon.json

# 启动docker
systemctl start docker 
# 设置开机自启动
systemctl enable docker

#在docker中安装mysql
mkdir ~/mysql
cd ~/mysql

# 手工创建conf,logs,data目录
# mkdir -p $PWD/conf
# mkdir -p $PWD/logs
# mkdir -p $PWD/data

docker run -di --name=mysql -p 3306:3306 \
-v $PWD/conf:/etc/mysql/conf.d  \
-v $PWD/logs:/logs \
-v $PWD/data:/var/lib/mysql  \
-e MYSQL_ROOT_PASSWORD=root  \
--privileged=true \
--restart=always mysql:5.7

# 安装redis
docker run -di --name=redis -p 6379:6379 --restart=always redis